﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using System.Windows.Controls;
using System.IO;

namespace USM_Presenter.ViewModels
{
    [Serializable()]
    public class PresentationViewModel : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(info));
        }

        #endregion
        public enum MenuPosition { Top, Bottom, Left, Right }

        public PresentationViewModel()
        {
            this.SlideShow = new SlideShowViewModel(this);
            Pages.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Pages_CollectionChanged);
        }

#if DEBUG
        [XmlIgnore]
        public const string EditPassword = "1";
#else
        [XmlIgnore]
        public const string EditPassword = "usm1234567890";
#endif

        private string _password;
        [XmlIgnore]
        public string Password
        {
            get { return _password; }
            set
            {
                if (value != _password)
                {
                    _password = value;
                    NotifyPropertyChanged("Password");
                    NotifyPropertyChanged("EditModeButtonEnabled");
                }
            }
        }

        public bool EditModeButtonEnabled
        {
            get { return Password == EditPassword; }
        }

        private bool _editMode = false;
        [XmlIgnore]
        public bool EditMode
        {
            get { return _editMode; }
            set
            {
                if (value != _editMode)
                {
                    this._editMode = value;
                    NotifyPropertyChanged("EditMode");
                }
            }
        }

        private bool _readOnly = false;
        public bool ReadOnly
        {
            get { return _readOnly; }
            set
            {
                if (_readOnly != value)
                {
                    _readOnly = value;
                    NotifyPropertyChanged("ReadOnly");
                    NotifyPropertyChanged("NotReadOnly");
                }
            }
        }

        public bool NotReadOnly
        {
            get { return !ReadOnly; }
        }

        private string _backgroundTempImage;
        private string _backgroundImage;
        public string BackgroundImage
        {
            get { return _backgroundImage; }
            set
            {
                if (value != _backgroundImage)
                {
                    _backgroundImage = value;
                    NotifyPropertyChanged("BackgroundImage");

                    if (_isAtHome)
                        _backgroundTempImage = _backgroundImage;
                }
            }
        }

        public SlideShowViewModel SlideShow { get; set; }

        #region Music
        private double _volume = 1;
        public double Volume
        {
            get { return _volume; }
            set
            {
                if (_volume != value)
                {
                    _volume = value;
                    NotifyPropertyChanged("Volume");
                }
            }
        }

        private string _music;
        public string Music
        {
            get { return _music; }
            set
            {
                if (_music != value)
                {
                    _music = value;
                    NotifyPropertyChanged("Music");
                }
            }
        }
        #endregion

        #region XML Works
        public void SerializeToXML(string FileName)
        {
            XmlSerializer serializer = new XmlSerializer(this.GetType());
            StreamWriter writer = new StreamWriter(FileName);
            serializer.Serialize(writer, this);
            writer.Close();
            serializer = null;
            writer.Dispose();
            writer = null;
            GC.Collect();
        }

        public static PresentationViewModel DeserializeFromXML(string FileName)
        {
            PresentationViewModel presentation = new PresentationViewModel();
            XmlSerializer serializer = new XmlSerializer(presentation.GetType());
            FileStream fs = new FileStream(FileName, FileMode.Open);
            presentation = (PresentationViewModel)(serializer.Deserialize(fs));
            serializer = null;
            fs.Dispose();
            fs = null;
            GC.Collect();

            foreach (PageViewModel p in presentation.Pages)
            {
                p.Parent = presentation;
                presentation._tempPages.Add(p);
                foreach (ThumbElementBase i in p.Elements)
                    i.Parent = p;
            }

            return presentation;
        }

        #endregion

        #region Page

        private bool _isAtHome = true;

        private List<PageViewModel> _tempPages = new List<PageViewModel>();

        private ObservableCollection<PageViewModel> _pages = new ObservableCollection<PageViewModel>();
        public ObservableCollection<PageViewModel> Pages
        {
            get { return _pages; }
            set
            {
                if (value != _pages)
                {
                    _pages = value;
                    NotifyPropertyChanged("Pages");
                }
            }
        }

        private void Pages_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {

        }

        private PageViewModel _selectedPage;
        [XmlIgnore]
        public PageViewModel SelectedPage
        {
            get { return _selectedPage; }
            set
            {
                if (value != _selectedPage)
                {
                    _selectedPage = value;

                    if (_selectedPage != null)
                    {
                        _isAtHome = false;
                        if (!string.IsNullOrEmpty(_selectedPage.PageBackgroundImage))
                            this.BackgroundImage = _selectedPage.PageBackgroundImage;

                        if (_selectedPage.UseAs == PageViewModel.UseAsEnum.Page)
                        {
                            Pages.Clear();
                            foreach (PageViewModel p in _selectedPage.Pages)
                                Pages.Add(p);
                        }
                    }

                    NotifyPropertyChanged("SelectedPage");
                }
            }
        }

        private VerticalAlignment _pagesPanelVerticalAlignment = VerticalAlignment.Center;
        public VerticalAlignment PagesPanelVerticalAlignment
        {
            get { return _pagesPanelVerticalAlignment; }
            set
            {
                if (value != _pagesPanelVerticalAlignment)
                {
                    _pagesPanelVerticalAlignment = value;
                    NotifyPropertyChanged("PagesPanelVerticalAlignment");
                }
            }
        }

        private HorizontalAlignment _pagesPanelHorizontalAlignment = HorizontalAlignment.Center;
        public HorizontalAlignment PagesPanelHorizontalAlignment
        {
            get { return _pagesPanelHorizontalAlignment; }
            set
            {
                if (value != _pagesPanelHorizontalAlignment)
                {
                    _pagesPanelHorizontalAlignment = value;
                    NotifyPropertyChanged("PagesPanelHorizontalAlignment");
                }
            }
        }

        private Orientation _pagesOrientation = Orientation.Horizontal;
        public Orientation PagesOrientation
        {
            get { return _pagesOrientation; }
            set
            {
                if (_pagesOrientation != value)
                {
                    _pagesOrientation = value;
                    NotifyPropertyChanged("PagesOrientation");

                    NotifyPropertyChanged("PagesOrientationHorizontal");
                    NotifyPropertyChanged("PagesOrientationVertical");
                }
            }
        }

        private SolidColorBrush _pagePanelBackground = new SolidColorBrush(Color.FromArgb(32, 0, 0, 0));
        [XmlIgnore]
        public SolidColorBrush PagePanelBackground
        {
            get { return _pagePanelBackground; }
            set
            {
                if (_pagePanelBackground != value)
                {
                    _pagePanelBackground = value;
                    NotifyPropertyChanged("PagePanelBackground");
                }
            }
        }

        private Thickness _pagePanelBorderThickness = new Thickness(1);
        [XmlIgnore]
        public Thickness PagePanelBorderThickness
        {
            get { return _pagePanelBorderThickness; }
            set
            {
                if (_pagePanelBorderThickness != value)
                {
                    _pagePanelBorderThickness = value;
                    NotifyPropertyChanged("PagePanelBorderThickness");
                }
            }
        }

        private bool _pagePanelEnabled = true;
        public bool PagePanelEnabled
        {
            get { return _pagePanelEnabled; }
            set
            {
                if (_pagePanelEnabled != value)
                {
                    _pagePanelEnabled = value;
                    NotifyPropertyChanged("PagePanelEnabled");

                    if (_pagePanelEnabled)
                    {
                        PagePanelBackground = new SolidColorBrush(Color.FromArgb(32, 0, 0, 0));
                        PagePanelBorderThickness = new Thickness(1);
                    }
                    else
                    {
                        PagePanelBackground = Brushes.Transparent;
                        PagePanelBorderThickness = new Thickness(0);
                    }
                }
            }
        }

        [XmlIgnore]
        public bool PagesOrientationHorizontal
        {
            get { return _pagesOrientation == Orientation.Horizontal; }
            set { PagesOrientation = Orientation.Horizontal; }
        }

        [XmlIgnore]
        public bool PagesOrientationVertical
        {
            get { return _pagesOrientation == Orientation.Vertical; }
            set { PagesOrientation = Orientation.Vertical; }
        }

        [XmlIgnore]
        public bool AlignPagesPanelLeftUp
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Left && _pagesPanelVerticalAlignment == VerticalAlignment.Top; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Left;
                PagesPanelVerticalAlignment = VerticalAlignment.Top;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelMidUp
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Center && _pagesPanelVerticalAlignment == VerticalAlignment.Top; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Center;
                PagesPanelVerticalAlignment = VerticalAlignment.Top;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelRightUp
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Right && _pagesPanelVerticalAlignment == VerticalAlignment.Top; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Right;
                PagesPanelVerticalAlignment = VerticalAlignment.Top;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }


        [XmlIgnore]
        public bool AlignPagesPanelLeftMid
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Left && _pagesPanelVerticalAlignment == VerticalAlignment.Center; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Left;
                PagesPanelVerticalAlignment = VerticalAlignment.Center;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelMidMid
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Center && _pagesPanelVerticalAlignment == VerticalAlignment.Center; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Center;
                PagesPanelVerticalAlignment = VerticalAlignment.Center;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelRightMid
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Right && _pagesPanelVerticalAlignment == VerticalAlignment.Center; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Right;
                PagesPanelVerticalAlignment = VerticalAlignment.Center;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelLeftDown
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Left && _pagesPanelVerticalAlignment == VerticalAlignment.Bottom; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Left;
                PagesPanelVerticalAlignment = VerticalAlignment.Bottom;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelMidDown
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Center && _pagesPanelVerticalAlignment == VerticalAlignment.Bottom; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Center;
                PagesPanelVerticalAlignment = VerticalAlignment.Bottom;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        [XmlIgnore]
        public bool AlignPagesPanelRightDown
        {
            get { return _pagesPanelHorizontalAlignment == HorizontalAlignment.Right && _pagesPanelVerticalAlignment == VerticalAlignment.Bottom; }
            set
            {
                PagesPanelHorizontalAlignment = HorizontalAlignment.Right;
                PagesPanelVerticalAlignment = VerticalAlignment.Bottom;

                NotifyPropertyChanged("AlignPagesPanelLeftUp");
                NotifyPropertyChanged("AlignPagesPanelMidUp");
                NotifyPropertyChanged("AlignPagesPanelRightUp");

                NotifyPropertyChanged("AlignPagesPanelLeftMid");
                NotifyPropertyChanged("AlignPagesPanelMidMid");
                NotifyPropertyChanged("AlignPagesPanelRightMid");

                NotifyPropertyChanged("AlignPagesPanelLeftDown");
                NotifyPropertyChanged("AlignPagesPanelMidDown");
                NotifyPropertyChanged("AlignPagesPanelRightDown");
            }
        }

        private int _pageFontSize = 36;
        public int PageFontSize
        {
            get { return _pageFontSize; }
            set
            {
                if (value != _pageFontSize)
                {
                    _pageFontSize = value;
                    NotifyPropertyChanged("PageFontSize");
                }
            }
        }

        private string _pageFont;
        public string PageFont
        {
            get { return _pageFont; }
            set
            {
                if (value != _pageFont)
                {
                    _pageFont = value;
                    NotifyPropertyChanged("PageFont");
                }
            }
        }

        private Color _pageForeColor = Colors.Black;
        public Color PageForeColor
        {
            get { return _pageForeColor; }
            set
            {
                if (_pageForeColor != value)
                {
                    _pageForeColor = value;
                    NotifyPropertyChanged("PageForeColor");
                    NotifyPropertyChanged("PageForeColorBrush");
                }
            }
        }

        public SolidColorBrush PageForeColorBrush
        {
            get { return new SolidColorBrush(_pageForeColor); }
        }

        private PageViewModel FindPage(Guid g)
        {
            for (int i = 0; i < Pages.Count; i++)
                if (Pages[i].PrimaryID == g)
                    return Pages[i];

            return null;
        }

        internal void AddNewPage(PageViewModel.UseAsEnum useas)
        {
            PageViewModel p = new PageViewModel(this, useas);
            this.Pages.Add(p);

            if (_isAtHome)
                _tempPages.Add(p);
            else
                SelectedPage.Pages.Add(p);
        }

        internal void DeletePage(Guid g)
        {
            PageViewModel p = FindPage(g);
            if (p != null)
            {
                this.Pages.Remove(p);

                if (_isAtHome)
                    _tempPages.Remove(p);
                else
                    SelectedPage.Pages.Remove(p);
            }
        }

        internal void SelectPage(Guid g)
        {
            PageViewModel p = FindPage(g);
            SelectedPage = p;
        }

        #endregion

        #region Navigation Menu
        private MenuPosition _navMenuPositon = MenuPosition.Top;
        public MenuPosition NavMenuPosition
        {
            get { return _navMenuPositon; }
            set
            {
                if (_navMenuPositon != value)
                {
                    _navMenuPositon = value;
                    NotifyPropertyChanged("NavMenuPosition");

                    NotifyPropertyChanged("NavGridRow");
                    NotifyPropertyChanged("NavGridCol");
                    NotifyPropertyChanged("NavGridColSpan");
                    NotifyPropertyChanged("NavGridRowSpan");

                    NotifyPropertyChanged("IsNavMenuPositionTop");
                    NotifyPropertyChanged("IsNavMenuPositionLeft");
                    NotifyPropertyChanged("IsNavMenuPositionRight");
                    NotifyPropertyChanged("IsNavMenuPositionBottom");
                }
            }
        }

        [XmlIgnore]
        public int NavGridRow
        {
            get
            {
                if (NavMenuPosition == MenuPosition.Bottom)
                    return 2;

                return 0;
            }
        }

        [XmlIgnore]
        public int NavGridCol
        {
            get
            {
                if (NavMenuPosition == MenuPosition.Right)
                    return 2;

                return 0;
            }
        }

        [XmlIgnore]
        public int NavGridColSpan
        {
            get
            {
                if (NavMenuPosition == MenuPosition.Top || NavMenuPosition == MenuPosition.Bottom)
                    return 3;

                return 1;
            }
        }

        [XmlIgnore]
        public int NavGridRowSpan
        {
            get
            {
                if (NavMenuPosition == MenuPosition.Left || NavMenuPosition == MenuPosition.Right)
                    return 3;

                return 1;
            }
        }

        [XmlIgnore]
        public bool IsNavMenuPositionTop
        {
            get { return NavMenuPosition == MenuPosition.Top; }
            set
            {
                if (ThumbPosition == MenuPosition.Top) return;
                if (value) NavMenuPosition = MenuPosition.Top;
            }
        }

        [XmlIgnore]
        public bool IsNavMenuPositionBottom
        {
            get { return NavMenuPosition == MenuPosition.Bottom; }
            set
            {
                if (ThumbPosition == MenuPosition.Bottom) return;
                if (value) NavMenuPosition = MenuPosition.Bottom;
            }
        }

        [XmlIgnore]
        public bool IsNavMenuPositionLeft
        {
            get { return NavMenuPosition == MenuPosition.Left; }
            set
            {
                if (ThumbPosition == MenuPosition.Left) return;
                if (value) NavMenuPosition = MenuPosition.Left;
            }
        }

        [XmlIgnore]
        public bool IsNavMenuPositionRight
        {
            get { return NavMenuPosition == MenuPosition.Right; }
            set
            {
                if (ThumbPosition == MenuPosition.Right) return;
                if (value) NavMenuPosition = MenuPosition.Right;
            }
        }

        private HorizontalAlignment _navHAlignment = HorizontalAlignment.Left;
        public HorizontalAlignment NavHAlignment
        {
            get { return _navHAlignment; }
            set
            {
                if (value != _navHAlignment)
                {
                    _navHAlignment = value;
                    NotifyPropertyChanged("NavHAlignment");
                }
            }
        }

        private VerticalAlignment _navVAlignment = VerticalAlignment.Top;
        public VerticalAlignment NavVAlignment
        {
            get { return _navVAlignment; }
            set
            {
                if (value != _navVAlignment)
                {
                    _navVAlignment = value;
                    NotifyPropertyChanged("NavVAlignment");
                }
            }
        }

        [XmlIgnore]
        public bool IsNavMenuContentLeft
        {
            get { return NavHAlignment == HorizontalAlignment.Left; }
            set
            {
                if (value)
                {
                    NavHAlignment = HorizontalAlignment.Left;
                    NavVAlignment = VerticalAlignment.Top;
                }
            }
        }

        [XmlIgnore]
        public bool IsNavMenuContentRight
        {
            get { return NavHAlignment == HorizontalAlignment.Right; }
            set
            {
                if (value)
                {
                    NavHAlignment = HorizontalAlignment.Right;
                    NavVAlignment = VerticalAlignment.Bottom;
                }
            }
        }

        [XmlIgnore]
        public bool IsNavMenuContentCenter
        {
            get { return NavHAlignment == HorizontalAlignment.Center; }
            set
            {
                if (value)
                {
                    NavHAlignment = HorizontalAlignment.Center;
                    NavVAlignment = VerticalAlignment.Center;
                }
            }
        }

        private int _navFontSize = 26;
        public int NavFontSize
        {
            get { return _navFontSize; }
            set
            {
                if (value != _navFontSize)
                {
                    _navFontSize = value;
                    NotifyPropertyChanged("NavFontSize");
                }
            }
        }

        private string _navFont;
        public string NavFont
        {
            get { return _navFont; }
            set
            {
                if (value != _navFont)
                {
                    _navFont = value;
                    NotifyPropertyChanged("NavFont");
                }
            }
        }

        private Color _navForeColor = Colors.Black;
        public Color NavForeColor
        {
            get { return _navForeColor; }
            set
            {
                if (_navForeColor != value)
                {
                    _navForeColor = value;
                    NotifyPropertyChanged("NavForeColor");
                    NotifyPropertyChanged("NavForeColorBrush");
                }
            }
        }

        [XmlIgnore]
        public SolidColorBrush NavForeColorBrush
        {
            get { return new SolidColorBrush(_navForeColor); }
        }

        private string _navButton1_Content = "Başlangıç";
        public string NavButton1_Content
        {
            get { return _navButton1_Content; }
            set
            {
                if (value != _navButton1_Content)
                {
                    _navButton1_Content = value;
                    NotifyPropertyChanged("NavButton1_Content");
                }
            }
        }

        private string _navButton2_Content = "Çal";
        public string NavButton2_Content
        {
            get { return _navButton2_Content; }
            set
            {
                if (value != _navButton2_Content)
                {
                    _navButton2_Content = value;
                    NotifyPropertyChanged("NavButton2_Content");
                }
            }
        }

        private string _navButton3_Content = "Durdur";
        public string NavButton3_Content
        {
            get { return _navButton3_Content; }
            set
            {
                if (value != _navButton3_Content)
                {
                    _navButton3_Content = value;
                    NotifyPropertyChanged("NavButton3_Content");
                }
            }
        }

        private string _navButton4_Content = "Sessiz";
        public string NavButton4_Content
        {
            get { return _navButton4_Content; }
            set
            {
                if (value != _navButton4_Content)
                {
                    _navButton4_Content = value;
                    NotifyPropertyChanged("NavButton4_Content");
                }
            }
        }

        private string _navButton5_Content = "Slayt Şov";
        public string NavButton5_Content
        {
            get { return _navButton5_Content; }
            set
            {
                if (value != _navButton5_Content)
                {
                    _navButton5_Content = value;
                    NotifyPropertyChanged("NavButton5_Content");
                }
            }
        }

        private string _navButton6_Content = "Geri";
        public string NavButton6_Content
        {
            get { return _navButton6_Content; }
            set
            {
                if (value != _navButton6_Content)
                {
                    _navButton6_Content = value;
                    NotifyPropertyChanged("NavButton6_Content");
                }
            }
        }

        private string _navButton7_Content = "Çıkış";
        public string NavButton7_Content
        {
            get { return _navButton7_Content; }
            set
            {
                if (value != _navButton7_Content)
                {
                    _navButton7_Content = value;
                    NotifyPropertyChanged("NavButton7_Content");
                }
            }
        }

        private bool _navButton1_Visibility = true;
        public bool NavButton1_Visibility
        {
            get { return _navButton1_Visibility; }
            set
            {
                if (_navButton1_Visibility != value)
                {
                    _navButton1_Visibility = value;
                    NotifyPropertyChanged("NavButton1_Visibility");
                }
            }
        }

        private bool _navButton2_Visibility = true;
        public bool NavButton2_Visibility
        {
            get { return _navButton2_Visibility; }
            set
            {
                if (_navButton2_Visibility != value)
                {
                    _navButton2_Visibility = value;
                    NotifyPropertyChanged("NavButton2_Visibility");
                }
            }
        }

        private bool _navButton3_Visibility = true;
        public bool NavButton3_Visibility
        {
            get { return _navButton3_Visibility; }
            set
            {
                if (_navButton3_Visibility != value)
                {
                    _navButton3_Visibility = value;
                    NotifyPropertyChanged("NavButton3_Visibility");
                }
            }
        }

        private bool _navButton4_Visibility = false;
        public bool NavButton4_Visibility
        {
            get { return _navButton4_Visibility; }
            set
            {
                if (_navButton4_Visibility != value)
                {
                    _navButton4_Visibility = value;
                    NotifyPropertyChanged("NavButton4_Visibility");
                }
            }
        }

        private bool _navButton5_Visibility = true;
        public bool NavButton5_Visibility
        {
            get { return _navButton5_Visibility; }
            set
            {
                if (_navButton5_Visibility != value)
                {
                    _navButton5_Visibility = value;
                    NotifyPropertyChanged("NavButton5_Visibility");
                }
            }
        }

        private bool _navButton6_Visibility = true;
        public bool NavButton6_Visibility
        {
            get { return _navButton6_Visibility; }
            set
            {
                if (_navButton6_Visibility != value)
                {
                    _navButton6_Visibility = value;
                    NotifyPropertyChanged("NavButton6_Visibility");
                }
            }
        }

        private bool _navButton7_Visibility = true;
        public bool NavButton7_Visibility
        {
            get { return _navButton7_Visibility; }
            set
            {
                if (_navButton7_Visibility != value)
                {
                    _navButton7_Visibility = value;
                    NotifyPropertyChanged("NavButton7_Visibility");
                }
            }
        }

        private bool _volumeSliderVisibility = true;
        public bool VolumeSliderVisibility
        {
            get { return _volumeSliderVisibility; }
            set
            {
                if (_volumeSliderVisibility != value)
                {
                    _volumeSliderVisibility = value;
                    NotifyPropertyChanged("VolumeSliderVisibility");
                }
            }
        }

        private string _nav1Image = "images/ButtonNone.png";
        public string Nav1Image
        {
            get { return _nav1Image; }
            set
            {
                if (value != _nav1Image)
                {
                    _nav1Image = value;
                    NotifyPropertyChanged("Nav1Image");
                }
            }
        }

        private string _nav2Image = "images/ButtonNone.png";
        public string Nav2Image
        {
            get { return _nav2Image; }
            set
            {
                if (value != _nav2Image)
                {
                    _nav2Image = value;
                    NotifyPropertyChanged("Nav2Image");
                }
            }
        }

        private string _nav3Image = "images/ButtonNone.png";
        public string Nav3Image
        {
            get { return _nav3Image; }
            set
            {
                if (value != _nav3Image)
                {
                    _nav3Image = value;
                    NotifyPropertyChanged("Nav3Image");
                }
            }
        }

        private string _nav4Image = "images/ButtonNone.png";
        public string Nav4Image
        {
            get { return _nav4Image; }
            set
            {
                if (value != _nav4Image)
                {
                    _nav4Image = value;
                    NotifyPropertyChanged("Nav4Image");
                }
            }
        }

        private string _nav5Image = "images/ButtonNone.png";
        public string Nav5Image
        {
            get { return _nav5Image; }
            set
            {
                if (value != _nav5Image)
                {
                    _nav5Image = value;
                    NotifyPropertyChanged("Nav5Image");
                }
            }
        }

        private string _nav6Image = "images/ButtonNone.png";
        public string Nav6Image
        {
            get { return _nav6Image; }
            set
            {
                if (value != _nav6Image)
                {
                    _nav6Image = value;
                    NotifyPropertyChanged("Nav6Image");
                }
            }
        }

        private string _nav7Image = "images/ButtonNone.png";
        public string Nav7Image
        {
            get { return _nav7Image; }
            set
            {
                if (value != _nav7Image)
                {
                    _nav7Image = value;
                    NotifyPropertyChanged("Nav7Image");
                }
            }
        }

        private bool _translateButtonVisible = true;
        public bool TranslateButtonVisible
        {
            get { return _translateButtonVisible; }
            set
            {
                if (_translateButtonVisible != value)
                {
                    _translateButtonVisible = value;
                    NotifyPropertyChanged("TranslateButtonVisible");
                }
            }
        }

        private bool _rotateButtonVisible = true;
        public bool RotateButtonVisible
        {
            get { return _rotateButtonVisible; }
            set
            {
                if (_rotateButtonVisible != value)
                {
                    _rotateButtonVisible = value;
                    NotifyPropertyChanged("RotateButtonVisible");
                }
            }
        }

        private bool _scaleButtonVisible = true;
        public bool ScaleButtonVisible
        {
            get { return _scaleButtonVisible; }
            set
            {
                if (_scaleButtonVisible != value)
                {
                    _scaleButtonVisible = value;
                    NotifyPropertyChanged("ScaleButtonVisible");
                }
            }
        }

        private bool _isTranslateEnabled = true;
        public bool IsTranslateEnabled
        {
            get { return _isTranslateEnabled; }
            set
            {
                if (value != _isTranslateEnabled)
                {
                    _isTranslateEnabled = value;
                    NotifyPropertyChanged("IsTranslateEnabled");
                }
            }
        }

        private bool _isRotateEnabled = false;
        public bool IsRotateEnabled
        {
            get { return _isRotateEnabled; }
            set
            {
                if (value != _isRotateEnabled)
                {
                    _isRotateEnabled = value;
                    NotifyPropertyChanged("IsRotateEnabled");
                }
            }
        }

        private bool _isScaleEnabled = true;
        public bool IsScaleEnabled
        {
            get { return _isScaleEnabled; }
            set
            {
                if (value != _isScaleEnabled)
                {
                    _isScaleEnabled = value;
                    NotifyPropertyChanged("IsScaleEnabled");
                }
            }
        }

        private string _translateONImage = "images/Buttons/kaydirma1.png";
        public string TranslateONImage
        {
            get { return _translateONImage; }
            set
            {
                if (value != _translateONImage)
                {
                    _translateONImage = value;
                    NotifyPropertyChanged("TranslateONImage");
                }
            }
        }

        private string _translateOFFImage = "images/Buttons/kaydirma2.png";
        public string TranslateOFFImage
        {
            get { return _translateOFFImage; }
            set
            {
                if (value != _translateOFFImage)
                {
                    _translateOFFImage = value;
                    NotifyPropertyChanged("TranslateOFFImage");
                }
            }
        }

        private string _rotateONImage = "images/Buttons/dondurme1.png";
        public string RotateONImage
        {
            get { return _rotateONImage; }
            set
            {
                if (value != _rotateONImage)
                {
                    _rotateONImage = value;
                    NotifyPropertyChanged("RotateONImage");
                }
            }
        }

        private string _rotateOFFImage = "images/Buttons/dondurme2.png";
        public string RotateOFFImage
        {
            get { return _rotateOFFImage; }
            set
            {
                if (value != _rotateOFFImage)
                {
                    _rotateOFFImage = value;
                    NotifyPropertyChanged("RotateOFFImage");
                }
            }
        }

        private string _scaleONImage = "images/Buttons/boyut1.png";
        public string ScaleONImage
        {
            get { return _scaleONImage; }
            set
            {
                if (value != _scaleONImage)
                {
                    _scaleONImage = value;
                    NotifyPropertyChanged("ScaleONImage");
                }
            }
        }

        private string _scaleOFFImage = "images/Buttons/boyut2.png";
        public string ScaleOFFImage
        {
            get { return _scaleOFFImage; }
            set
            {
                if (value != _scaleOFFImage)
                {
                    _scaleOFFImage = value;
                    NotifyPropertyChanged("ScaleOFFImage");
                }
            }
        }

        private string _sliderImage = "images/Slider.png";
        public string SliderImage
        {
            get { return _sliderImage; }
            set
            {
                if (value != _sliderImage)
                {
                    _sliderImage = value;
                    NotifyPropertyChanged("SliderImage");
                }
            }
        }

        private int _sliderWidth = 120;
        public int SliderWidth
        {
            get { return _sliderWidth; }
            set
            {
                if (value != _sliderWidth)
                {
                    _sliderWidth = value;
                    NotifyPropertyChanged("SliderWidth");
                }
            }
        }

        private int _sliderButtonWidth = 40;
        public int SliderButtonWidth
        {
            get { return _sliderButtonWidth; }
            set
            {
                if (value != _sliderButtonWidth)
                {
                    _sliderButtonWidth = value;
                    NotifyPropertyChanged("SliderButtonWidth");
                }
            }
        }

        private int _sliderButtonHeight = 40;
        public int SliderButtonHeight
        {
            get { return _sliderButtonHeight; }
            set
            {
                if (value != _sliderButtonHeight)
                {
                    _sliderButtonHeight = value;
                    NotifyPropertyChanged("SliderButtonHeight");
                }
            }
        }

        internal void GotoHome()
        {
            _isAtHome = true;
            if (_tempPages.Count <= 0) return;

            Pages.Clear();
            foreach (PageViewModel p in _tempPages)
                Pages.Add(p);

            SelectedPage = null;

            this.BackgroundImage = _backgroundTempImage;
        }

        internal void GoToBack()
        {
            if (_isAtHome) return;

            if (SelectedPage.ParentPage == null)
                GotoHome();
            else
                SelectedPage = SelectedPage.ParentPage;
        }

        #endregion

        #region Thumb
        private MenuPosition _thumbPositon = MenuPosition.Right;
        public MenuPosition ThumbPosition
        {
            get { return _thumbPositon; }
            set
            {
                if (_thumbPositon != value)
                {
                    _thumbPositon = value;
                    NotifyPropertyChanged("ThumbPosition");

                    NotifyPropertyChanged("ThumbGridRow");
                    NotifyPropertyChanged("ThumbGridCol");

                    NotifyPropertyChanged("IsThumbMenuPositionTop");
                    NotifyPropertyChanged("IsThumbMenuPositionLeft");
                    NotifyPropertyChanged("IsThumbMenuPositionRight");
                    NotifyPropertyChanged("IsThumbMenuPositionBottom");

                    NotifyPropertyChanged("ThumbOrientation");
                }
            }
        }

        [XmlIgnore]
        public Orientation ThumbOrientation
        {
            get
            {
                if (ThumbPosition == MenuPosition.Bottom || ThumbPosition == MenuPosition.Top)
                    return Orientation.Horizontal;
                else
                    return Orientation.Vertical;
            }
        }

        [XmlIgnore]
        public int ThumbGridRow
        {
            get
            {
                if (ThumbPosition == MenuPosition.Bottom)
                    return 2;

                if (ThumbPosition == MenuPosition.Top)
                    return 0;

                return 1;
            }
        }

        [XmlIgnore]
        public int ThumbGridCol
        {
            get
            {
                if (ThumbPosition == MenuPosition.Right)
                    return 2;

                if (ThumbPosition == MenuPosition.Left)
                    return 0;

                return 1;
            }
        }

        [XmlIgnore]
        public bool IsThumbPositionTop
        {
            get { return ThumbPosition == MenuPosition.Top; }
            set
            {
                if (NavMenuPosition == MenuPosition.Top) return;
                if (value) ThumbPosition = MenuPosition.Top;
            }
        }

        [XmlIgnore]
        public bool IsThumbPositionBottom
        {
            get { return ThumbPosition == MenuPosition.Bottom; }
            set
            {
                if (NavMenuPosition == MenuPosition.Bottom) return;
                if (value) ThumbPosition = MenuPosition.Bottom;
            }
        }

        [XmlIgnore]
        public bool IsThumbPositionLeft
        {
            get { return ThumbPosition == MenuPosition.Left; }
            set
            {
                if (NavMenuPosition == MenuPosition.Left) return;
                if (value) ThumbPosition = MenuPosition.Left;
            }
        }

        [XmlIgnore]
        public bool IsThumbPositionRight
        {
            get { return ThumbPosition == MenuPosition.Right; }
            set
            {
                if (NavMenuPosition == MenuPosition.Right) return;
                if (value) ThumbPosition = MenuPosition.Right;
            }
        }

        #endregion
    }
}